public class Main {
    public static String uppercaseFirst (String s) {
	return (char) (s.charAt(0) + 'А' - 'а') + s.substring (1);
    }

    public static void main (String[] args) {
	IAnimal[] animals = new IAnimal[] {
	    new Dog (" Спайк"),
	    new Frog (", която всъщност е принц"),
	    new Kitten (" Пухчо"),
	    new Tomcat (" Томпухчо")
	};

	for (IAnimal animal : animals) {
	    animal.talk ();
	}

	System.out.println();
	for (int i = 0; i < animals.length; i++) {
	    for (int j = 0; j < animals.length; j++) {
		if (i != j) {
		    System.out.print("Може ли "
				     + animals[i].getType(true)
				     + animals[i].getName()
				     + (animals[i] instanceof Frog ? "," : "")
				     + " да изяде "
				     + animals[j].getType(true)
				     + animals[j].getName()
				     + "? – ");

		    if (animals[i].couldEat(animals[j])) {
			System.out.println ("Да!");
		    } else {
			System.out.println ("Не!");
		    }
		}
	    }

	    System.out.println();
	}
    }
}
